import {
  Controller,
  Get,
  Param,
  UseGuards,
  Query,
  DefaultValuePipe,
  ParseIntPipe,
} from '@nestjs/common';
import { ProductService } from 'src/service/product.service';
import { QueryProductDto } from 'src/dto/query-product.dto';

@Controller('api/product')
export class ProductApiController {
  constructor(private readonly productService: ProductService) {}

  @Get()
  findAll(@Query() query: QueryProductDto) {
    console.log(
      '%c [ query ]-20',
      'font-size:13px; background:pink; color:#bf2c9f;',
      query,
    );
    return this.productService.query(query);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.productService.findOne(+id);
  }
}
